package com.xiaoshuidi.cloud.module.rooms.enums;

import cn.hutool.core.util.StrUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * @Author Feng
 * @date 2023/4/27
 * 资产方位
 */
@Getter
@AllArgsConstructor
public enum EquipmentStatus {

    LEAVE_UNUSED("1", "闲置"),
    MAINTENANCE("3", "维修中"),
    SCRAPPED("4", "报废"),
    LOSE("5", "遗失"),
    INUSE("6", "使用中");

    private String code;
    private String name;

    public static String getNameByCode(String code) {
        if (StrUtil.isEmpty(code)) {
            return null;
        }
        Optional<EquipmentStatus> find = Arrays.stream(EquipmentStatus.values()).filter(s -> ((s.getCode()).equals(code))).findFirst();
        if (find.isPresent()) {
            return find.get().getName();
        }
        return null;
    }

}
